package com.example.vhhj.service;

import com.example.vhhj.dao.TbUserDAO;
import com.example.vhhj.entity.TbUser;
import org.springframework.beans.factory.annotation.Autowired;
import  org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TbUserServiceImpl implements TbUserService {
    @Autowired
    private TbUserDAO tbUserDAO;

    @Override
    public List<TbUser> findAll() {
        return tbUserDAO.findAll();
    }

    @Override
    public String add(TbUser user) {
        int status = tbUserDAO.add(user);
        if (status>0){
            return "插入成功";
        }
        else{
            return "插入失败";
        }
    }

    @Override
    public String updateUser(TbUser user) {
        int status = tbUserDAO.updateUser(user);
        if (status>0){
            return "更新成功";
        }
        else{
            return "更新失败";
        }
    }

    @Override
    public String delUser(int id) {
        int status = tbUserDAO.delUser(id);
        if (status>0){
            return "删除成功";
        }
        else{
            return "删除失败";
        }
    }

    @Override
    public List<TbUser> queryByName(TbUser user) {
        return tbUserDAO.queryByName(user);
    }

    @Override
    public List<TbUser> queryLikeName(TbUser user) {
        return tbUserDAO.queryLikeName(user);
    }

    @Override
    public List<TbUser> queryByTiaojian(TbUser user) {
        return tbUserDAO.queryByTiaojian(user);
    }
}















